<?php

/**

 * aheadWorks Co.

 *

 * NOTICE OF LICENSE

 *

 * This source file is subject to the EULA

 * that is bundled with this package in the file LICENSE.txt.

 * It is also available through the world-wide-web at this URL:

 * http://ecommerce.aheadworks.com/LICENSE-M1.txt

 *

 * @category   AW

 * @package    AW_Mobile

 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)

 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt

 */



/**

 * Product view template

 *

 * @see Mage_Catalog_Block_Product_View

 */

?>

<script type="text/javascript">

    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);

</script>

<?php $_product=$this->getProduct() ?>

<form action="" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>

<div class="product-info-box">

    <div class="product-essential">

        <div class="product-shop">

            <div>

				<div class="product-name"><?php echo $this->helper('awmobile')->escapeHtml($_product->getName()) ?></div>

				<div class="product-sku" style="display:none;"><?php echo $_product->getSku() ?></div>
				
                <div class="product-images">                                        

                    <?php echo $this->getChildHtml('media');?>                    

                </div>

                <div style="padding-top:10px; border-top:1px solid #949494;">

                    <?php echo $this->getChildHtml('product_type_data') ?>

					<?php

					$ush = date("H");

					?>

					<div class="specials_countdown_view2_box">

					  <div class="specials_countdown_view2">

						<?php

							$h = 28-$ush; 

							if($h>23)

								$h-=24;

							$m = 60-date('i');

							$s = 60-date('s'); 

						?>

						<span id="otime" class="specials_countdown_time"> <span class="off_p"><?php echo sprintf('%.0f%%',(1-$_product->getFinalPrice()/$_product->getPrice())*100); ?> OFF</span> <span id="time_h">

						<?php if($h<10){echo "0".$h.":";}else{ echo $h.":"; } ?>

						</span> <span id="time_m">

						<?php if($m<10){echo "0".$m.":";}else{ echo $m.":"; } ?>

						</span> <span id="time_s">

						<?php if($s<10){echo "0".$s;}else{ echo $s; } ?>

						</span> <span class="left_p">left</span> </span>

						<script type="text/javascript">

							var _t; 

							var _h = <?php echo $h ?>; 

							var _m = <?php echo $m ?>; 

							var _s = <?php echo $s ?>; 

							var _v = formatTime(_h + 'h:' + _m + 'm:' + _s); 

					

							function doTime() { 

								_s --; 

								if (_s == -1) { 

									 _m --; 

									 _s = 59; 

								} 

								if (_m == -1) { 

									 _h --; 

									 _m = 59; 

								} 

								var _b = ((_h == 0) && (_m == 0) && (_s == 0)); 

								if (_b) { 

									_v = ''; 

									clearTimeout(_t); 

								} else { 

									_v = formatTime(_h + 'h:' + _m + 'm:' + _s + 's'); 

									_t = setTimeout('doTime()', 1000); 

								} 

								if(_h<10){$('time_h').innerHTML = "0"+_h+":";}else{$('time_h').innerHTML = _h+":";}

								if(_m<10){$('time_m').innerHTML = "0"+_m+":";}else{$('time_m').innerHTML = _m+":";}

								if(_s<10){$('time_s').innerHTML = "0"+_s;}else{$('time_s').innerHTML = _s;}

							} 

						   

							function formatTime(_time) { 

								return _time.replace(/\b(\w)\b/g, '0$1'); 

							} 

					

							onload = function() { 

								if(_h<10){$('time_h').innerHTML = "0"+_h+":";}else{$('time_h').innerHTML = _h+":";}

								if(_m<10){$('time_m').innerHTML = "0"+_m+":";}else{$('time_m').innerHTML = _m+":";}

								if(_s<10){$('time_s').innerHTML = "0"+_s;}else{$('time_s').innerHTML = _s;}

								_t = setTimeout('doTime()', 1000); 

							} 

						</script>

					  </div>

					</div>

					

					<?php

						$shipping_time="";

						if(array_key_exists("shipping_time" , $_product->getAttributes())){

							$shipping_time = $_product->getResource()->getAttribute('shipping_time')->getFrontend()->getValue($_product);

						}

					?>

					<?php if($shipping_time==$this->__('Yes')): ?>

					 <div class="shipping_time"></div>

					<?php endif; ?>

                    

                    <fieldset class="no-display">

                        <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" class="prodcut"/>

                        <input type="hidden" name="related_product" id="related-products-field" value="" class="prodcut"/>

                    </fieldset>



                    <script type="text/javascript">

                        var productAddToCartForm = new VarienForm('product_addtocart_form');

                        productAddToCartForm.submit = function(){

                                if (this.validator.validate()) {

                                     mobileCart.postProductForm('product_addtocart_form', '<?php echo $this->getAddToCartUrl($_product) ?>');

                                }

                        }.bind(productAddToCartForm);

                        $j(document).ready(function(e){

                            $j('#product_addtocart_form').submit(function(event){

                                $j(':focus').blur();

                                productAddToCartForm.submit();

                                return false;

                            });

                        });

                    </script>

                    <div class="clear"></div>



                </div>

               

                <div class="clear"></div>

            </div>

        </div>

            <?php if ($_product->isSaleable() && $this->hasOptions()):?>

                <?php echo $this->getChildChildHtml('container2', '', true, true) ?>

            <?php endif;?>

        </div>

    <div>

        <?php echo $this->getChildHtml('extrahint') ?>

                        

    </div>

	

	<?php echo $this->getChildHtml('currency') ?>

	

    <?php echo $this->getChildHtml('extra.product.info') ?>

        <?php echo $this->getChildHtml('prices'); ?>



        <?php if (!$this->hasOptions()):?>

            <?php if($_product->isSaleable()): ?>

                <?php echo $this->getChildHtml('addtocart') ?>

            <?php endif; ?>

        <?php endif; ?>

		<?php echo $this->getChildHtml('paypal_wrapper'); ?>

        <?php echo $this->getChildHtml('other');?>



        <?php if ($_product->isSaleable() && $this->hasOptions()):?>

            <?php echo $this->getChildChildHtml('container1', '', true, true) ?>

        <?php endif;?>
		
		
		

		<div class="customer-reviews">

			<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>

		</div>

		

        <div class="product-collatera">

        <?php echo $this->getTierPriceHtml() ?>



        <?php if(!method_exists($this, 'getChildGroup')): ?>

            <h4 class="product-details-collation-header"><?php echo $this->helper('awmobile')->escapeHtml($this->getChild('description')->getTitle());?></h4>

            <?php echo $this->getChildHtml('description') ?>

        <?php else: ?>

             



            <?php

                $this->getLayout()->getBlock('product.description')->addToParentGroup('detailed_info')->setTitle($this->__('Product Descriptions'));

            ?>



            <?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>

                <h4 class="product-details-collation-header"><?php echo $this->helper('awmobile')->escapeHtml($this->getChildData($alias, 'title'));?></h4>

                <div><?php echo $html;?></div>

            <?php endforeach;?>

        <?php endif; ?>



        <?php echo $this->getChildHtml('product_attributes_data') ?>





        <?php //echo $this->getChildHtml('upsell_products') ?>

        <?php //echo $this->getChildHtml('product_additional_data') ?>

    </div>

</div>

</form>

<?php echo $this->getChildHtml('product.siblings') ?>


<?php
if(array_key_exists("length" , $_product->getAttributes())){
	$_product_length = $_product->getResource()->getAttribute('length')->getFrontend()->getValue($_product);
}
if(array_key_exists("color_new" , $_product->getAttributes())){
	$_product_color = $_product->getResource()->getAttribute('color_new')->getFrontend()->getValue($_product);
}
?>
<script type="text/javascript">
jQuery(function(){
	var product_length = '<?php echo $_product_length ?>';
	var product_color = '<?php echo $_product_color ?>';
	jQuery('select.selectlength option').each(function(){
		if(jQuery(this).text().indexOf(product_length) > -1){
			jQuery(this).attr('selected','selected');
		}
	});
	jQuery('select.selectcolor option').each(function(){
		if(jQuery(this).text().indexOf(product_color) > -1){
			jQuery(this).attr('selected','selected');
		}
	});
});
</script>